/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package systole.view.crud.tableModels;

import java.math.BigDecimal;
import java.util.List;
import systole.domain.signals.SignalFrequency;

/**
 *
 * @author jmj
 */
public class SignalFrequencyTableModel extends SystoleTableModel<SignalFrequency> {

    private String[] columnNames = {"Descripción", "Frecuencia"};
    private static final int FREQUENCY_INDEX = 1;
    private static final int DESCRIPTION_INDEX =0;

    /**
     *
     * @param frequencies
     */
    public SignalFrequencyTableModel(List<SignalFrequency> frequencies) {
        super(frequencies);
    }


    public int getColumnCount() {
        return this.columnNames.length;
    }

    public String getColumnName(int column) {
        return this.columnNames[column];
    }

    public Class<?> getColumnClass(int column) {
        switch (column) {
            case FREQUENCY_INDEX:
                return Double.class;
            case DESCRIPTION_INDEX:
                return String.class;
        }
        return null;
    }

    public Object getValueAt(int row, int column) {
        switch (column) {
            case FREQUENCY_INDEX:
                return this.entities.get(row).getFrequency();
            case DESCRIPTION_INDEX:
                return this.entities.get(row).getDescription();
        }
        return null;
    }

    public void setValueAt(Object value, int row, int column) {
        switch (column) {
            case FREQUENCY_INDEX:
                this.entities.get(row).setFrequency((BigDecimal) value);
                break;
            case DESCRIPTION_INDEX:
                this.entities.get(row).setDescription((String) value);
                break;
        }
    }


}
